package com.jxm.bootstudy.listener;

import com.jxm.bootstudy.pojo.User;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @Author: jxm
 * @Description: 自定义监听器
 * @Date: 2024-1-5 15:15
 * @Version: 1.0
 */
@Component
public class MyEventListener implements ApplicationListener<MyEvent> {

    @Override
    public void onApplicationEvent(MyEvent myEvent) {
        // 把事件中的信息获取到
        User user = myEvent.getUser();
        // 处理事件，实际项目中可以通知别的微服务或者处理其他逻辑等等
        System.out.println("用户名：" + user.getName());
        System.out.println("密码：" + user.getPassword());
    }
}
